
package ConversorDWDM.view;

import java.awt.Desktop;
import java.awt.Toolkit;
import java.io.File;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Principal extends javax.swing.JFrame
{    
    Double freq, comp_onda, chanel, chanel1, Disp;
    Double c = 299792458.00;
    int porta;
    String Banda_DWDM;
    Boolean radio;
    
    public Principal()
    {
        initComponents();
        setIcon();
    }
     
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jFrame1 = new javax.swing.JFrame();
        jFrame2 = new javax.swing.JFrame();
        jFrame3 = new javax.swing.JFrame();
        jFrame4 = new javax.swing.JFrame();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        popupMenu1 = new java.awt.PopupMenu();
        popupMenu2 = new java.awt.PopupMenu();
        popupMenu3 = new java.awt.PopupMenu();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jDialog1 = new javax.swing.JDialog();
        buttonGroup3 = new javax.swing.ButtonGroup();
        buttonGroup4 = new javax.swing.ButtonGroup();
        buttonGroup5 = new javax.swing.ButtonGroup();
        buttonGroup6 = new javax.swing.ButtonGroup();
        Label_Frequencia = new javax.swing.JLabel();
        Frequencia = new javax.swing.JTextField();
        Label_THz = new javax.swing.JLabel();
        Label_nm = new javax.swing.JLabel();
        Comprimento_Onda = new javax.swing.JTextField();
        Label_Comp_Onda = new javax.swing.JLabel();
        Banda = new javax.swing.JTextField();
        Label_Banda = new javax.swing.JLabel();
        Label_Canal = new javax.swing.JLabel();
        Porta = new javax.swing.JTextField();
        Label_Porta = new javax.swing.JLabel();
        Canal = new javax.swing.JFormattedTextField();
        Panel_Banda = new javax.swing.JPanel();
        Radio_C_Par = new javax.swing.JRadioButton();
        Radio_C_Impar = new javax.swing.JRadioButton();
        Radio_L_Impar = new javax.swing.JRadioButton();
        Radio_L_Par = new javax.swing.JRadioButton();
        Painel_Status = new javax.swing.JPanel();
        Label_Canal_Invalido = new javax.swing.JLabel();
        Painel_Botoes = new javax.swing.JPanel();
        Sair = new javax.swing.JButton();
        Botao_Limpar = new javax.swing.JButton();
        Botao_Tabela = new javax.swing.JButton();
        Botao_Converter = new javax.swing.JButton();
        Painel_Nome_Programa = new javax.swing.JPanel();
        Label_Título_Programa = new javax.swing.JLabel();
        Label_Dispersão = new javax.swing.JLabel();
        Dispersao = new javax.swing.JTextField();
        Label_Simb_Dispersao = new javax.swing.JLabel();
        Barra_Menus = new javax.swing.JMenuBar();
        Menu_Sobre = new javax.swing.JMenu();
        Opcao_Sobre = new javax.swing.JMenuItem();
        Opcao_Sair = new javax.swing.JMenuItem();
        Ajuda_Ajuda = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        Menu_Treinamento = new javax.swing.JMenuItem();

        jFrame1.setIconImages(getIconImages());

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jFrame2Layout = new javax.swing.GroupLayout(jFrame2.getContentPane());
        jFrame2.getContentPane().setLayout(jFrame2Layout);
        jFrame2Layout.setHorizontalGroup(
            jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame2Layout.setVerticalGroup(
            jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jFrame3Layout = new javax.swing.GroupLayout(jFrame3.getContentPane());
        jFrame3.getContentPane().setLayout(jFrame3Layout);
        jFrame3Layout.setHorizontalGroup(
            jFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame3Layout.setVerticalGroup(
            jFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jFrame4Layout = new javax.swing.GroupLayout(jFrame4.getContentPane());
        jFrame4.getContentPane().setLayout(jFrame4Layout);
        jFrame4Layout.setHorizontalGroup(
            jFrame4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame4Layout.setVerticalGroup(
            jFrame4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane2.setViewportView(jTextArea1);

        popupMenu1.setLabel("popupMenu1");

        popupMenu2.setLabel("popupMenu2");

        popupMenu3.setLabel("popupMenu3");

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema DWDM");
        setBackground(new java.awt.Color(255, 102, 0));

        Label_Frequencia.setText("Frequência:");

        Frequencia.setEditable(false);
        Frequencia.setBackground(new java.awt.Color(204, 204, 255));
        Frequencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FrequenciaActionPerformed(evt);
            }
        });

        Label_THz.setText("THz");

        Label_nm.setText("nm");

        Comprimento_Onda.setEditable(false);
        Comprimento_Onda.setBackground(new java.awt.Color(204, 204, 255));
        Comprimento_Onda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Comprimento_OndaActionPerformed(evt);
            }
        });

        Label_Comp_Onda.setText("Comprimento de Onda:");

        Banda.setEditable(false);
        Banda.setBackground(new java.awt.Color(204, 204, 255));
        Banda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BandaActionPerformed(evt);
            }
        });

        Label_Banda.setText("Banda:");

        Label_Canal.setText("Canal:");

        Porta.setEditable(false);
        Porta.setBackground(new java.awt.Color(204, 204, 255));
        Porta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PortaActionPerformed(evt);
            }
        });

        Label_Porta.setText("Porta Mux/Demux:");

        Canal.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        Canal.setColumns(0);
        Canal.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        Panel_Banda.setBackground(new java.awt.Color(204, 204, 204));
        Panel_Banda.setBorder(javax.swing.BorderFactory.createTitledBorder("Banda"));

        Radio_C_Par.setSelected(true);
        Radio_C_Par.setText("Banda C Par");
        Radio_C_Par.setAutoscrolls(true);
        Radio_C_Par.setContentAreaFilled(false);
        Radio_C_Par.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        Radio_C_Par.setDoubleBuffered(true);
        Radio_C_Par.setFocusCycleRoot(true);
        Radio_C_Par.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Radio_C_ParActionPerformed(evt);
            }
        });

        Radio_C_Impar.setText("Banda C Ímpar");
        Radio_C_Impar.setContentAreaFilled(false);
        Radio_C_Impar.setEnabled(false);
        Radio_C_Impar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Radio_C_ImparActionPerformed(evt);
            }
        });

        Radio_L_Impar.setText("Banda L Ímpar");
        Radio_L_Impar.setContentAreaFilled(false);
        Radio_L_Impar.setEnabled(false);
        Radio_L_Impar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Radio_L_ImparActionPerformed(evt);
            }
        });

        Radio_L_Par.setText("Banda L Par");
        Radio_L_Par.setAutoscrolls(true);
        Radio_L_Par.setContentAreaFilled(false);
        Radio_L_Par.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        Radio_L_Par.setDoubleBuffered(true);
        Radio_L_Par.setEnabled(false);
        Radio_L_Par.setFocusCycleRoot(true);
        Radio_L_Par.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Radio_L_ParActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout Panel_BandaLayout = new javax.swing.GroupLayout(Panel_Banda);
        Panel_Banda.setLayout(Panel_BandaLayout);
        Panel_BandaLayout.setHorizontalGroup(
            Panel_BandaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Panel_BandaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Radio_C_Par)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Radio_C_Impar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(Radio_L_Par)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Radio_L_Impar)
                .addContainerGap())
        );
        Panel_BandaLayout.setVerticalGroup(
            Panel_BandaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Panel_BandaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(Panel_BandaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(Panel_BandaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(Radio_L_Impar)
                        .addComponent(Radio_L_Par))
                    .addGroup(Panel_BandaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(Radio_C_Impar)
                        .addComponent(Radio_C_Par)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        Radio_C_Par.getAccessibleContext().setAccessibleDescription("Banda C");

        Painel_Status.setBackground(new java.awt.Color(204, 204, 204));
        Painel_Status.setBorder(javax.swing.BorderFactory.createTitledBorder("Status"));

        Label_Canal_Invalido.setBackground(new java.awt.Color(255, 102, 0));
        Label_Canal_Invalido.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Label_Canal_Invalido.setForeground(new java.awt.Color(204, 0, 0));
        Label_Canal_Invalido.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Label_Canal_Invalido.setText("Digite o canal...");
        Label_Canal_Invalido.setAutoscrolls(true);

        javax.swing.GroupLayout Painel_StatusLayout = new javax.swing.GroupLayout(Painel_Status);
        Painel_Status.setLayout(Painel_StatusLayout);
        Painel_StatusLayout.setHorizontalGroup(
            Painel_StatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Painel_StatusLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Label_Canal_Invalido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        Painel_StatusLayout.setVerticalGroup(
            Painel_StatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Painel_StatusLayout.createSequentialGroup()
                .addComponent(Label_Canal_Invalido)
                .addGap(0, 1, Short.MAX_VALUE))
        );

        Painel_Botoes.setBorder(javax.swing.BorderFactory.createTitledBorder("Botões"));

        Sair.setText("Fechar");
        Sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SairActionPerformed(evt);
            }
        });

        Botao_Limpar.setText("Limpar");
        Botao_Limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Botao_LimparActionPerformed(evt);
            }
        });

        Botao_Tabela.setBackground(new java.awt.Color(0, 255, 102));
        Botao_Tabela.setText("Ver tabela");
        Botao_Tabela.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Botao_TabelaActionPerformed(evt);
            }
        });

        Botao_Converter.setBackground(new java.awt.Color(255, 175, 175));
        Botao_Converter.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        Botao_Converter.setText("Converter");
        Botao_Converter.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Botao_Converter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Botao_ConverterActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout Painel_BotoesLayout = new javax.swing.GroupLayout(Painel_Botoes);
        Painel_Botoes.setLayout(Painel_BotoesLayout);
        Painel_BotoesLayout.setHorizontalGroup(
            Painel_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Painel_BotoesLayout.createSequentialGroup()
                .addComponent(Botao_Tabela, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(41, 41, 41)
                .addComponent(Botao_Limpar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(43, 43, 43)
                .addComponent(Sair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Painel_BotoesLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(Botao_Converter, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(117, 117, 117))
        );
        Painel_BotoesLayout.setVerticalGroup(
            Painel_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Painel_BotoesLayout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(Botao_Converter, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(Painel_BotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Sair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Botao_Limpar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Botao_Tabela, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        Botao_Converter.getAccessibleContext().setAccessibleDescription("Converter");

        Painel_Nome_Programa.setBackground(new java.awt.Color(240, 150, 145));
        Painel_Nome_Programa.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Programa", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(255, 255, 255)));
        Painel_Nome_Programa.setToolTipText("Dados do Programa");
        Painel_Nome_Programa.setAutoscrolls(true);
        Painel_Nome_Programa.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        Label_Título_Programa.setBackground(new java.awt.Color(255, 102, 0));
        Label_Título_Programa.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        Label_Título_Programa.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Label_Título_Programa.setText("Conversor de Frequências para Sistemas DWDM");
        Label_Título_Programa.setAutoscrolls(true);

        javax.swing.GroupLayout Painel_Nome_ProgramaLayout = new javax.swing.GroupLayout(Painel_Nome_Programa);
        Painel_Nome_Programa.setLayout(Painel_Nome_ProgramaLayout);
        Painel_Nome_ProgramaLayout.setHorizontalGroup(
            Painel_Nome_ProgramaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Painel_Nome_ProgramaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Label_Título_Programa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        Painel_Nome_ProgramaLayout.setVerticalGroup(
            Painel_Nome_ProgramaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Label_Título_Programa, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
        );

        Label_Dispersão.setText("Dispersão Cromática (L = 1km):");

        Dispersao.setEditable(false);
        Dispersao.setBackground(new java.awt.Color(204, 204, 255));
        Dispersao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DispersaoActionPerformed(evt);
            }
        });

        Label_Simb_Dispersao.setText("ps/nm.km");

        Menu_Sobre.setMnemonic('O');
        Menu_Sobre.setText("Opções");
        Menu_Sobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Menu_SobreActionPerformed(evt);
            }
        });

        Opcao_Sobre.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        Opcao_Sobre.setMnemonic('S');
        Opcao_Sobre.setText("Sobre");
        Opcao_Sobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Opcao_SobreActionPerformed(evt);
            }
        });
        Menu_Sobre.add(Opcao_Sobre);

        Opcao_Sair.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        Opcao_Sair.setMnemonic('E');
        Opcao_Sair.setText("Sair");
        Opcao_Sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Opcao_SairActionPerformed(evt);
            }
        });
        Menu_Sobre.add(Opcao_Sair);

        Barra_Menus.add(Menu_Sobre);

        Ajuda_Ajuda.setText("Ajuda");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("Ajuda");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        Ajuda_Ajuda.add(jMenuItem1);

        Menu_Treinamento.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        Menu_Treinamento.setText("Treinamento");
        Menu_Treinamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Menu_TreinamentoActionPerformed(evt);
            }
        });
        Ajuda_Ajuda.add(Menu_Treinamento);

        Barra_Menus.add(Ajuda_Ajuda);

        setJMenuBar(Barra_Menus);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Painel_Status, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Panel_Banda, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(Label_Frequencia)
                                    .addComponent(Label_Comp_Onda)
                                    .addComponent(Label_Canal))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 107, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(Frequencia, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(Comprimento_Onda, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(Canal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(Label_Banda)
                                    .addComponent(Label_Porta))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(Porta, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(Banda, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(Label_Dispersão)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(Dispersao, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Label_nm)
                            .addComponent(Label_THz)
                            .addComponent(Label_Simb_Dispersao))
                        .addGap(9, 9, 9))
                    .addComponent(Painel_Nome_Programa, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(Painel_Botoes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Painel_Nome_Programa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Painel_Status, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Panel_Banda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Label_Canal, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(Canal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Frequencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label_THz)
                    .addComponent(Label_Frequencia))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Comprimento_Onda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label_nm)
                    .addComponent(Label_Comp_Onda))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Dispersao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label_Dispersão)
                    .addComponent(Label_Simb_Dispersao))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Banda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label_Banda))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Porta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label_Porta))
                .addGap(17, 17, 17)
                .addComponent(Painel_Botoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        getAccessibleContext().setAccessibleDescription("Conversor de Canais DWDM");

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    // Botão Sobre Menu Opções
    private void Opcao_SobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Opcao_SobreActionPerformed
        JOptionPane.showMessageDialog(this, "Sistema Desenvolvido por:"
                + "\nTárcio Lima da Silva\ntarcio.nina@gmail.com\nVersão: 1.0", "Sobre o sistema", 
                JOptionPane.PLAIN_MESSAGE, null);
    }//GEN-LAST:event_Opcao_SobreActionPerformed

    // Botão Sobre Menu Sair
    private void Opcao_SairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Opcao_SairActionPerformed
        System.exit(0);
    }//GEN-LAST:event_Opcao_SairActionPerformed

    private void BandaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BandaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_BandaActionPerformed

    private void Botao_ConverterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Botao_ConverterActionPerformed
      Label_Canal_Invalido.setText(String.valueOf("Digite o canal..."));
      chanel = Double.parseDouble(Canal.getText());
      
      radio = Radio_C_Par.isSelected();
      
      if(radio == true)
      {
          
      }
      
      if(chanel == null)
      {
          Label_Canal_Invalido.setText(String.valueOf("Digite o canal..."));
      }
      else
      {
          if( (chanel >= 21) && (chanel <= 60) )
          {
            // Inclusão do número após a vírgula
            chanel = chanel / 10.00;
            freq = 190.00 + chanel;
            Frequencia.setText(String.valueOf(freq + "0"));

            // Conversão de Frquência para Comprimento de Onda
            comp_onda = c / freq / 1000;
            
            // Mostra frequência com duas casas decimais
            NumberFormat formatter = new DecimalFormat("#,###.00");
            String s = formatter.format(comp_onda);
            
            // Mostra o comprimento de onda no campo Comprimento de Onda
            Comprimento_Onda.setText(String.valueOf(s));

            //Mostra a Dispersão Cromática do Canal
            Disp = 1 * (17 + 0.056 * (comp_onda - 1550));
            NumberFormat formatDisp = new DecimalFormat("###.00");
            String formDispersao = formatDisp.format(Disp);
            Dispersao.setText(String.valueOf(formDispersao));
            
            // Verificação da Banda (Ainda não está implantada)
            if(chanel % 2 == 0)
            { Banda_DWDM = "C Par"; }
            else
            { Banda_DWDM = "C Par"; }

            // Mostra a Banda do CAnal no campo Banda
            Banda.setText(String.valueOf(Banda_DWDM));

            // Cálculo para descobrir a porta física do canal informado na placa M40/D40
            chanel = Double.parseDouble(Canal.getText());
            porta = (int) (40 - (chanel - 21));
            Porta.setText(String.valueOf(porta));
            Label_Canal_Invalido.setText(String.valueOf("Cálculo OK !"));
        }
        else
        {
            Canal.setText("");
            Frequencia.setText("");
            Comprimento_Onda.setText("");
            Banda.setText("");
            Porta.setText("");
            Dispersao.setText("");
            Label_Canal_Invalido.setText(String.valueOf("Canal Inválido!  Banda C: do Canal 21 ao 60"));
            Frequencia.setText("");
        } 
      }
    }//GEN-LAST:event_Botao_ConverterActionPerformed

    private void SairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SairActionPerformed
        System.exit(0);
    }//GEN-LAST:event_SairActionPerformed

    private void Comprimento_OndaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Comprimento_OndaActionPerformed
     //
    }//GEN-LAST:event_Comprimento_OndaActionPerformed

    private void FrequenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FrequenciaActionPerformed
        //
    }//GEN-LAST:event_FrequenciaActionPerformed

    private void Botao_TabelaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Botao_TabelaActionPerformed
        JFrame tabela = new Tabela();
        tabela.setVisible(true);
    }//GEN-LAST:event_Botao_TabelaActionPerformed

    private void PortaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PortaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_PortaActionPerformed

    private void Botao_LimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Botao_LimparActionPerformed
        Canal.setText(null);
        Frequencia.setText(null);
        Comprimento_Onda.setText(null);
        Banda.setText(null);
        Porta.setText(null);
        Dispersao.setText(null);
        Label_Canal_Invalido.setText(String.valueOf("Digite o canal..."));
    }//GEN-LAST:event_Botao_LimparActionPerformed
    
    private void Menu_SobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Menu_SobreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Menu_SobreActionPerformed

    private void Radio_C_ParActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Radio_C_ParActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Radio_C_ParActionPerformed

    private void Radio_C_ImparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Radio_C_ImparActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Radio_C_ImparActionPerformed

    private void Radio_L_ImparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Radio_L_ImparActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Radio_L_ImparActionPerformed

    private void Radio_L_ParActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Radio_L_ParActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Radio_L_ParActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        JOptionPane.showMessageDialog(this, "Menu ajuda em Desenvolvimento\n\nImplantado apenas a Banda C Par"
                + "\n\nEnsel Engenharia LTDA", "Ajuda do sistema", JOptionPane.PLAIN_MESSAGE, null);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void DispersaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DispersaoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_DispersaoActionPerformed

    private void Menu_TreinamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Menu_TreinamentoActionPerformed
        // TODO add your handling code here:
        File pdf = new File("E:\\Projetos Informática\\ConversorDWDM\\src\\ConversorDWDM\\view\\Treinamento_DWDM.pdf");  
            try
            {
                Desktop.getDesktop().open(pdf);  
            } catch(Exception ex)
            { 
              ex.printStackTrace();  
              JOptionPane.showMessageDialog(null, "Erro no Desktop: " + ex);  
            } 
    }//GEN-LAST:event_Menu_TreinamentoActionPerformed
    
    public static void main(final String args[])
    { 
        try{
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu Ajuda_Ajuda;
    private javax.swing.JTextField Banda;
    private javax.swing.JMenuBar Barra_Menus;
    private javax.swing.JButton Botao_Converter;
    private javax.swing.JButton Botao_Limpar;
    private javax.swing.JButton Botao_Tabela;
    private javax.swing.JFormattedTextField Canal;
    private javax.swing.JTextField Comprimento_Onda;
    private javax.swing.JTextField Dispersao;
    private javax.swing.JTextField Frequencia;
    private javax.swing.JLabel Label_Banda;
    private javax.swing.JLabel Label_Canal;
    private javax.swing.JLabel Label_Canal_Invalido;
    private javax.swing.JLabel Label_Comp_Onda;
    private javax.swing.JLabel Label_Dispersão;
    private javax.swing.JLabel Label_Frequencia;
    private javax.swing.JLabel Label_Porta;
    private javax.swing.JLabel Label_Simb_Dispersao;
    private javax.swing.JLabel Label_THz;
    private javax.swing.JLabel Label_Título_Programa;
    private javax.swing.JLabel Label_nm;
    private javax.swing.JMenu Menu_Sobre;
    private javax.swing.JMenuItem Menu_Treinamento;
    private javax.swing.JMenuItem Opcao_Sair;
    private javax.swing.JMenuItem Opcao_Sobre;
    private javax.swing.JPanel Painel_Botoes;
    private javax.swing.JPanel Painel_Nome_Programa;
    private javax.swing.JPanel Painel_Status;
    private javax.swing.JPanel Panel_Banda;
    private javax.swing.JTextField Porta;
    private javax.swing.JRadioButton Radio_C_Impar;
    private javax.swing.JRadioButton Radio_C_Par;
    private javax.swing.JRadioButton Radio_L_Impar;
    private javax.swing.JRadioButton Radio_L_Par;
    private javax.swing.JButton Sair;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.ButtonGroup buttonGroup4;
    private javax.swing.ButtonGroup buttonGroup5;
    private javax.swing.ButtonGroup buttonGroup6;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JFrame jFrame2;
    private javax.swing.JFrame jFrame3;
    private javax.swing.JFrame jFrame4;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea1;
    private java.awt.PopupMenu popupMenu1;
    private java.awt.PopupMenu popupMenu2;
    private java.awt.PopupMenu popupMenu3;
    // End of variables declaration//GEN-END:variables

    private void setIcon()
    {
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("color.png")));
    }
}
